package com.financing.platform.dao.impl;

import java.util.List;
import com.financing.platform.dao.impl.BaseDaoImpl;
import com.financing.platform.dao.IFpFundManagerDao;
import com.financing.platform.dto.FpFundManagerDTO;
import com.financing.platform.util.SqlName;
import java.sql.SQLException;
import java.util.Collections;

import org.springframework.stereotype.Repository;

/**
 * @Description:实现类
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Repository("fpFundManager")
public class FpFundManagerDaoImpl extends BaseDaoImpl implements IFpFundManagerDao {
	
	@Override
	public FpFundManagerDTO getFpFundManager(FpFundManagerDTO dto) {
		try{
			return (FpFundManagerDTO)this.sqlMapClient.queryForObject(SqlName.fpFundManager,dto);
		} catch (SQLException e) {
			log.error("get fpFundManager error:",e);
			return null;
		}
	}
	
	
	@Override
	public Integer insertFpFundManager(FpFundManagerDTO dto) {
		try {
		     return (Integer) this.sqlMapClient.insert(SqlName.insertFpFundManager,dto);
		} catch (SQLException e) {
			log.error("add fpFundManager error:",e);
			return 0;
		}
	}

	
	@Override
	public Integer updateFpFundManager(FpFundManagerDTO dto) {
		try {
			return (Integer) this.sqlMapClient.update(SqlName.updateFpFundManager, dto);
		} catch (SQLException e) {
			this.log.error("update fpFundManager error 1!",e);
			return 0;
		}
	}
	
	@Override
	public Integer delFpFundManager(Integer id) {
		try{
			 return (Integer) this.sqlMapClient.delete(SqlName.delFpFundManager, id);
		} catch (SQLException e) {
			log.error("del fpFundManager error:",e);
			return 0;
		}
	}
	
	@Override
	public List<FpFundManagerDTO> listFpFundManager(FpFundManagerDTO dto) {
		try {
			return (List<FpFundManagerDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundManager, dto);
		} catch (SQLException e) {
			log.error("Query fpFundManager note list error !", e);
			return Collections.emptyList();
		}
	}
	
	
	public Integer countFpFundManager(FpFundManagerDTO dto){
		try {
			return (Integer)this.sqlMapClient.queryForObject(SqlName.countFpFundManager, dto);
		} catch (SQLException e) {
			log.error("Query fpFundManager note list error !", e);
			return 0;
		}
	}
	
	
	public List<FpFundManagerDTO> listFpFundManagerByCompanyId(String companyId){
		try {
			return (List<FpFundManagerDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundManagerByCompanyId, companyId);
		} catch (SQLException e) {
			log.error("Query fpFundManager note list error !", e);
			return Collections.emptyList();
		}
	}
	
	public List<FpFundManagerDTO> listFpFundManagerByFundId(String FundId){
		try {
			return (List<FpFundManagerDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundManagerByFundId, FundId);
		} catch (SQLException e) {
			log.error("Query fpFundManager note list error !", e);
			return Collections.emptyList();
		}
	}
}
